import java.util.Arrays;

public class Test {

    public static void bobbleSort(Comparable [] comparables){
        for (int i = 0; i < comparables.length - 1; i++) {
            for (int j = 0; j < comparables.length - 1 - i; j++) {
                if(comparables[j].compareTo(comparables[j + 1]) > 0){
                    Comparable tmp = comparables[j];
                    comparables[j] = comparables[j + 1];
                    comparables[j + 1] = tmp;
                }
            }
        }
    }

    public static void main1(String[] args) {
        Student student1 = new Student("鹏鹏",24);
        Student student2 = new Student("Jim",20);
        Student student3 = new Student("昊亚",21);

        Student [] students = new Student[3];
        students[0] = student1;
        students[1] = student2;
        students[2] = student3;

        System.out.println(Arrays.toString(students));

        bobbleSort(students);
//        Arrays.sort(students);

        System.out.println(Arrays.toString(students));

    }

    public static void main(String[] args) {
        Student student1 = new Student("南俊",24);
        Student student2 = new Student("汉堡侠",20);

        AgeComparator ageComparator = new AgeComparator();
        int ret1 = ageComparator.compare(student1,student2);
//        int ret = student1.compareTo(student2);

        System.out.println("根据年龄比较：");
        if(ret1 == 0){
            System.out.println("一样大");
        } else if (ret1 > 0) {
            System.out.println(student1.name + "更大");
        }else{
            System.out.println(student2.name + "更大");
        }
        System.out.println("根据姓名比较：");
        NameComparator nameComparator = new NameComparator();
        int ret2 = nameComparator.compare(student1,student2);
        if(ret2 == 0){
            System.out.println("一样大");
        } else if (ret2 > 0) {
            System.out.println(student1.name + "更大");
        }else{
            System.out.println(student2.name + "更大");
        }

    }




}
